import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;

public class decimoackermann {

	
	public static void main(String[] args) throws IOException {
		int n1;
		int n2;
		String frase = "";
		System.out.println("digite m");
		BufferedReader opcion = new BufferedReader(new InputStreamReader(System.in));
		frase = opcion.readLine();
		n1 = Integer.parseInt(frase);
		System.out.println("digite el n");
		BufferedReader opcion1 = new BufferedReader(new InputStreamReader(System.in));
		frase = opcion1.readLine();
		n2 = Integer.parseInt(frase);
		int r = ackermann(n1,n2);
		System.out.println(r);

	}

	public static int ackermann(int m, int n) {


		if (m == 0){
			return ( n+1 );
		}


		else{			
			if ( n == 0 ){
				return ackermann ( m-1, 1);
			}

			else{

				return ackermann ( m-1, ackermann ( m, n-1 ));
			}

		} 		

	}

}
